import axios from "@/util/request.js";

const api = {

    //退出登陆
    logout() {
        return axios.get("/logout");
    },
    //登录
    login(data) {
        return axios.post("/login",data);
    },
    //注册验证码
    enrollCaptcha(data) {
        return axios.get("/captcha/enroll?email="+data);
    },
    //获取登录验证码
    getCaptcha(){
        return axios.get("/captcha");
    },
    //注册
    enroll(data) {
        return axios.post("/user/enroll",data);
    },
    //更新个人信息
    saveUserInfo(data) {
        return axios.put("/user",data);
    },
    //注销账号
    logoff() {
        return axios.delete("/user");
    },



    //分页查询文章数据
    getArticlePage(current, size, kind) {
        return axios.get("/essay/paginatedQueries?current=" + current + "&size=" + size + "&kind=" + kind);
    },
    //根据id查询文章数据
    getArticleById(id) {
        return axios.get("/essay/" + id);
    },
    //根据id查询文章数据
    getHotArticle(kind) {
        let kinds = "";
        for (let i = 0; i < kind.length; i++) {
            if (i !== 0) {
                kinds += '&';
            }
            kinds += ('kind=' + kind[i]);
        }
        return axios.get("/essay/hotArticle?" + kinds);
    },
    //文章模糊搜索
    essaySearch(current,size,title){
        return axios.get("/essay/search?current=" + current + "&size=" + size + "&kind=" + title);
    },
    //点赞的增减操作
    supportPut(wid,bool){
        return axios.put("/essay/support?wid=" + wid +"&bool="+ bool);
    },
    //检查文章是否已点赞
    supportStatue(wid){
        return axios.get("/essay/supportStatue/" + wid);
    },
    //文章浏览增加
    articleVisit(id) {
        return axios.get("/essay/visit?id=" + id);
    },










    //反馈信息以及入职邮件发送
    getFeedback(data){
        return axios.post("/job",data);
    },
    //常见问题信息获取
    getProblemsPage(current,size,issue) {
        return axios.get("/faqs/selectAll?current=" + current + "&size=" + size + "&issue=" + issue);
    },


    //新增评论
    commentsAdd(data){
        return axios.post("/comments/add", data);
    },
    //获取所有文章详情评论
    commentsPageLevel(data){
        return axios.get("/comments/all?eid="+data);
    },
    //获取未读评论长度
    getCommentSize(){
        return axios.get("/comments/size");
    },
    //已读评论
    readComment(id){
        if(id){
            return axios.get("/comments/read?id="+id);
        }
    },
    //分页获取未读评论信息
    getUnread(current){
        return axios.get("/comments/unread?current="+current);
    },
    //统计文章评论个数
    countComment(data){
        return axios.get("/comments/count/"+data);
    },



    //获取指定网站配置信息
    homeCarousel(msg){
        return axios.get("/web/"+msg);
    }
}

export default api;